package cn.edu.cug.cs.gtl.apis.ui.devicetree;

import cn.edu.cug.cs.gtl.apis.ui.AbstractApplication;
import cn.edu.cug.cs.gtl.apis.ui.tree.Tree;
import cn.edu.cug.cs.gtl.apis.ui.tree.TreeSelectionListener;

import javax.swing.event.TreeSelectionEvent;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;
public class DeviceTreeSelectionListener extends TreeSelectionListener {

    public DeviceTreeSelectionListener(Tree tree, AbstractApplication theApp) {
        super(tree, theApp);
    }

    @Override
    public void valueChanged(TreeSelectionEvent e) {
        TreePath treePath = e.getPath();
        DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) treePath.getLastPathComponent();
        theApp.getMainFrame().getDevicePanel().getTreeComponent().setCurrentSelectedNode(treeNode);

        Object refObject  =  treeNode.getUserObject();
        if(refObject instanceof String){
            //Do Nothing
            String s = (String)refObject;
        }
        else{
            //Do Nothing

        }

    }

    @Override
    protected void objectChanged(Object obj) {

    }
}
